package leetcode.每日一题;

import org.junit.Test;

/**
 * @author ：zsy
 * @date ：Created 2022/11/30 8:41 PM
 * @description：
 */
public class 生成交替二进制字符串的最少操作数 {
    @Test
    public void test() {

    }

    class Solution {
        public int minOperations(String s) {
            int cnt = 0;
            for (int i = 0; i < s.length(); i++) {
                char c = s.charAt(i);
                if (c != (char)('0' + i % 2)) {
                    cnt++;
                }
            }
            return Math.min(cnt, s.length() - cnt);
        }
    }
}
